{layout name="pub/pub_css_js" /}
<script type="text/javascript" src="/static/js/vue2.5.1.js"></script>
<script src="/static/js/axios.min.js"></script>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 服务商<span
        class="c-gray en">&gt;</span> 服务商文章列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                               href="/admin/Dynamic/Dynamiclist" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container" id="app">
    <div class="text-c">
        <span class="select-box inline">
		<select name="status" id="status" v-model="status" class="select">
			<option value="0">待审核</option>
			<option value="4">审核拒绝</option>
			<option value="2">审核通过</option>
		</select>
		</span>
        <input type="text" name="keyword" id="keyword" v-model="keyword" placeholder=" 动态标题或者文章内容关键词" style="width:300px"
               class="input-text">
        <input type="text" name="service_id" id="service_id" v-model="service_id" placeholder="服务商id" style="width:300px"
               class="input-text">
        <button name="" @click="goComment" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i>
            搜内容
        </button>
    </div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
            <thead>
            <tr class="text-c">

                <th width=160">动态id</th>
                <th width=160">服务商id</th>
                <th>动态标题</th>
                <th width="60"> 展示图片</th>
                <th width="60">审核状态</th>
                <th width="140">提交时间</th>
                <th width="120">预览提交信息</th>
                <th width="120">操作</th>
            </tr>
            </thead>
            <tbody>

            {foreach $data as $vo}
            <tr class="text-c">
                <td>{$vo['dynamic_id']}</td>
                <td>{$vo['service_id']}</td>
                <td>{$vo['title']}</td>
                <td>
                    <img src="{$vo['show_image']}" alt="" width="100px;" height="100px">
                </td>
                <td>
                    {if condition="$vo['status'] eq 4"}
                    审核拒绝
                    {elseif condition="$vo['status'] eq 2"/}
                    审核通过
                    {elseif condition="$vo['status'] eq 0" /} 待审核
                    {/if}
                </td>
                <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
                <td class="text-l">
                    <a href="javascript:void(0)" class="btn btn-primary radius"
                       @click="openDetail('{$vo[\'dynamic_id\']}')">预览</a>
                </td>
                <td class="f-14 td-manage">
                    {if condition="($vo['status'] == 0 )"}
                    <a href="javascript:void(0)" class="btn btn-primary radius"
                       @click="To_Examine('{$vo[\'dynamic_id\']}',2)">通过</a>
                    <a href="javascript:void(0)" class="btn btn-danger radius"
                       @click="show_refuse('{$vo[\'dynamic_id\']}')">拒绝</a>
                    {/if}
                </td>
            </tr>
            {/foreach}
            </tbody>

        </table>
        <div class="mt-20">
            {$data->render()}
        </div>
    </div>
    <div id="refuse" v-show="refuse" class="custom-layer">
        请输入拒绝原因:
        <ul>
            <li v-for='(list,index) in lists'>
                <input v-model="list.value"  class="input-text" style="width: 260px ;margin-top: 5px" placeholder="请输入拒绝原因"/>
                <button v-on:click='lists.splice(index, 1)' class="btn btn-danger radius" >删除</button>
            </li>
        </ul>
        <button @click='addNewList' class="btn btn-warning radius" style="margin-top: 5px">添加拒绝原因</button>
        <button @click='ExamineService' class="btn btn-success radius" >提交</button>
        <button @click='Cancel_Res' class="btn btn-danger radius">取消</button>
    </div>
</div>
<style>
    .custom-layer {
        margin:0 auto;
        background: #5eb5e0;
        width: 80%;
        padding: 10px;
        -webkit-border-radius: 10px;
        -moz-border-radius: 10px;
        border-radius: 10px;
        font: 16px "Microsoft YaHei UI";
    }
</style>
<script>
    new Vue({
        el: '#app',
        data: {
            audit_msg: '',
            refuse: false,
            newAddText: '',
            dynamic_id: '',
            status: "{$search['status']}",
            keyword: "{$search['keyword']}",
            service_id: "{$search['service_id']}",
            lists: [
                {value: ''},
            ],
            options: [
                {
                    value: '2',
                    label: '步骤二(基本信息)'
                }, {
                    value: '3',
                    label: '步骤三(证明信息)'
                }],
            refuse_step: 4
        },
        created() {
            this.refuse_step = this.options[0].value;
        },
        methods: {
            goComment() {
                window.location.href = '/admin/Dynamic/Dynamiclist?status=' + this.status + '&keyword=' + this.keyword+ '&service_id=' + this.service_id;
            },
            Cancel_Res() {
                this.refuse = false;
            },
            To_Examine(dynamic_id, status) {
                console.log(status)
                if (status == 2) {
                    layer.confirm('确定要审核成功吗？', {
                        btn: ['确定', '取消'] //按钮
                    }, function () {
                        axios.post('/admin/Dynamic/ExamineDynamic',
                            {
                                dynamic_id: dynamic_id,
                                status: status,
                                request_type: 'h5',
                            }
                        ).then(response => {
                            if (response.data.status == 200) {
                                window.location.reload();
                            } else {
                                layer.alert(response.data.msg)
                            }
                        })
                    });
                }
            },
            openDetail(dynamic_id) {
                layer.open({
                    type: 2,
                    title: '预览动态详情',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['800px', '70%'],
                    content: '/admin/Dynamic/DynamicDetail?dynamic_id=' + dynamic_id
                });
            },
            addNewList: function () {
                this.lists.push({
                    value: this.newAddText
                })
                this.newAddText = ''
            },
            show_refuse: function (dynamic_id) {
                this.dynamic_id = dynamic_id
                this.refuse = true;
            },
            ExamineService: function () {
                if (this.lists[0].value.length > 1) {
                    axios.post('/admin/Dynamic/ExamineDynamic',
                        {
                            dynamic_id: this.dynamic_id,
                            status: 4,
                            request_type: 'h5',
                            error_message: this.lists,
                        }
                    ).then(response => {
                        if (response.data.status == 200) {
                            this.refuse = false;
                            this.lists = {value: ''};
                            location.reload()
                        } else {
                            layer.alert(response.data.msg)
                        }
                    })
                } else {
                    layer.alert('请填写拒绝原因!')
                }

            }
        }
    });
</script>



